<?php

/**
 * 前台 案例 模块 Model
 * ============================================================================
 * TBlog TBlog博客系统　BY Tmac PHP MVC framework
 * $Author: zwt007 $  <zwttmac@qq.com>
 * $Id: anli.class.php 31 2011-07-11 15:25:51Z zwt007 $
 * http://www.t-mac.org；
 */
class anli extends Model
{

    private $article_table;
    private $category_table;
    private $addonarticle_table;
    private $addonimages_table;

    /**
     * 初始化变量　定义私有变量
     */
    public function _init()
    {
        //连接数据库
        $this->connect();
        $this->article_table = '#@__article';
        $this->category_table = '#@__category';
        $this->addonarticle_table = '#@__addonarticle';
        $this->addonimages_table = '#@__addonimages';
    }

    /**
     * 获取一个资讯栏目信息
     * @param int $class_id 栏目id
     * return array
     */
    public function getAnliInfo($aid)
    {
        $sql = "SELECT a.*, b.imgurls, b.content FROM $this->article_table a LEFT JOIN $this->addonimages_table b ON a.article_id = b.article_id WHERE a.article_id = '$aid' LIMIT 0,1";

        $rs = $this->db->getRow($sql);
        return $rs;
    }

    /**
     * 取案例文章列表
     * @param <type> $limit
     * @return <type>
     */
    public function getAnliList($limit=1)
    {
        $sql = "SELECT * FROM $this->article_table WHERE channel = '2' LIMIT 0,{$limit}";
        $rs = $this->db->getAll($sql);
        return $rs;
    }

}